package exfist;
/**
 * @author brianmaccarthy
 */

import java.awt.Point;
import java.awt.image.BufferedImage;

public class Node
{
	/**
	 * TODO: Needs to check collisions,also needs a collision class :)
	 */
	// Instance variables: 
	private  Node child;
	protected Point pos;
	protected String node_name;
	protected boolean has_child;
	protected BufferedImage sprite;
	protected Collisions col;
	/** Creates a node with null references to its  
	contents & child node. */ 
	public  Node() 
	{
		this("",null, null); 
	} 
	/** Creates a node with the given contents and next node. */ 
    public  Node(String name,BufferedImage s,Point p)  
    { 
    	node_name = name;
    	sprite = s;
    	pos = p;
    	has_child=false;
    	col = new Collisions(pos,sprite,true);
    }
    // Accessor methods:
    protected BufferedImage getSprite()
    {
    	return sprite;
    }
    protected int getPos_X()
    {
    	return pos.x;
    }
    protected int getPos_Y()
    {
    	return pos.y;
    }
    protected boolean hasChild()
    {
    	return has_child;
    }
    protected String getNodeName()
    {
    	return node_name;
    }
    protected Node getChild()  
    {
    	if(has_child!=false)
    		return  child;
    	else
    		System.out.println("No child here");
    	return null;
    } 
    // Modifier methods:
    protected void setSprite(BufferedImage s)
    {
    	sprite=s;
    }
    protected void setPos_X(int x)
    {
    	pos.x=x;
    }
    protected void setPos_Y(int y)
    {
    	pos.y=y;
    }
    protected void setPos(Point new_pos)
    {
    	pos = new_pos;
    }
    protected void  setChild(Node newChild)  
    {
    	child  =  newChild; 
    	has_child = true;
    }
    protected void removeChild(Node bad_parent)
    {
    	if(bad_parent.hasChild())
    	{
    		bad_parent.setChild(null);
        	bad_parent.has_child=false;
    	}
    }
}
